import React, { Component } from 'react'
import TwsLayout from './components/tws-layout'
import { LocaleProvider } from 'antd'
import { IntlProvider } from 'react-intl'
import locales from './locales'
import { connect } from 'react-redux'
import { HashRouter as Router, Route } from 'react-router-dom'
import ReportStatisticBody from './components/tutor/tutor-program/statistics/report-statistic-body'
import TutorTaskPageBody from './components/common/task/tutor-task-page-body'
import TutorSectionListPageBody from './components/tutor/tutor-section-list/tutor-section-list-page-body'
import TutorProgramPageBody from './components/tutor/tutor-program/tutor-program-page-body'
import TutoredProgramListPageBody from './components/tutor/tutor-program-list/tutor-program-list-page-body'
import FollowerLinkPageBody from './components/follower-link-page-body'
import ProgramOverviewBody from './components/tutor/tutor-program/statistics/program-overview/program-overview-body'
import ProgramAssignmentsBody from './components/tutor/tutor-program/statistics/program-student-assignment/program-assignments-body'
import AssignmentsQuizBody from './components/tutor/tutor-program/statistics/assignment-quiz-overview/assignments-quiz-body'
import AssignmentsBasicQuizzesBody from './components/tutor/tutor-program/statistics/assignment-basic-quiz-overview/assignments-basic-quizzes-body'
import AssignmentsSurveyQuizzesBody from './components/tutor/tutor-program/statistics/assignment-survey-quiz-overview/assignments-survey-quizzes-body'
import ProgramAssignmentsTagBody from './components/tutor/tutor-program/statistics/program-student-assignment-tag-overview/program-assignments-tag-body'
import AssignmentsFinishSpeedOverviewBody from './components/tutor/tutor-program/statistics/assignment-finish-speed-overview/assignments-finish-speed-overview-body'
import { getLangFromLocalStorage } from './constant/lang-util'

class App extends Component {
  render () {
    const lang = this.props.lang || getLangFromLocalStorage()
    const langData = locales[lang]
    return (
      <IntlProvider locale={langData.intlLocale} messages={langData.intlMessage}>
        <LocaleProvider locale={langData.locale}>
          <Router>
            <TwsLayout lang={lang}>
              <Route exact path='/' component={TutoredProgramListPageBody} />
              <Route exact path='/program/:programId/task/:taskId/student/:studentId' component={TutorTaskPageBody} />
              <Route exact path='/program/:programId' component={TutorProgramPageBody} />
              <Route exact path='/program/:programId/student/:studentId' component={TutorSectionListPageBody} />
              <Route exact path='/programs/followers/links' component={FollowerLinkPageBody} />
              <Route exact path='/programs/:programId/reports' component={ReportStatisticBody} />
              <Route exact path='/programs/:programId/reports/program-overview' component={ProgramOverviewBody} />
              <Route exact path='/programs/:programId/reports/program-assignments-status' component={ProgramAssignmentsBody} />
              <Route exact path='/programs/:programId/reports/program-assignments-finish-report' component={AssignmentsQuizBody} />
              <Route exact path='/programs/:programId/reports/basic-quiz-statistic' component={AssignmentsBasicQuizzesBody} />
              <Route exact path='/programs/:programId/reports/survey-quiz-statistic' component={AssignmentsSurveyQuizzesBody} />
              <Route exact path='/programs/:programId/reports/program-assignments-tag-statistic' component={ProgramAssignmentsTagBody} />
              <Route exact path='/programs/:programId/reports/program-assignments-finish-speed-report' component={AssignmentsFinishSpeedOverviewBody} />
            </TwsLayout>
          </Router>
        </LocaleProvider>
      </IntlProvider>

    )
  }
}

const mapStateToProps = ({lang}) => ({lang})

export default connect(mapStateToProps)(App)
